@include('public.head')
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="">
        <div>
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>
                        账号添加
                    </h5>
                </div>
                <div class="ibox-content">
                    <form method="post" action="" class="form-horizontal m-t">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">账号</label>
                            <div class="col-sm-6">
                                <input type="text"  name="account" class="form-control file" style="padding:4px 12px" value="">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                          <label class="col-sm-2 control-label">密码</label>
                          <div class="col-sm-10">
                            <input type="password" class="form-control" name="pwd" value="">
                          </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        
                        <div class="form-group">
                          <label class="col-sm-2 control-label">确认密码</label>
                          <div class="col-sm-10">
                            <input type="password" class="form-control" name="config_pwd" value="">
                          </div>
                        </div>
                        <div class="hr-line-dashed"></div>


                        <input type="hidden" name="id" value="">
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                               <button class="btn btn-primary">保存</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
    $(".m-t").submit(function(e){
        var form = new FormData();

        var account = $("input[name='account']").val();
        var pwd = $("input[name='pwd']").val();
        var config_pwd = $("input[name='config_pwd']").val();
        
        if(pwd != config_pwd){
            layer.msg('密码不一致!');
            return false;
        } 

        form.append("account", account);
        form.append("pwd", pwd);
    
        $.ajax({
            url:"/add_admin_do",    //请求的url地址
            dataType:"json",   //返回格式为json
            data:form,    //参数值
            processData: false,
            contentType: false,   
            type:"POST",   //请求方式
            success:function(req){
                //请求成功时处理
                if(req.status == 0){
                    layer.msg(req.message);
                    return false;
                }
                   
                layer.msg('操作成功！');
                // setTimeout(function(){
                //      window.location.href = "/administrator";
                // },1000);
            }
        });
        return false;
    });
</script>
</body>
</html>